gchar *text;
gdouble angle;
+ gfloat xalign;
+ gfloat yalign;
guint mnemonics_visible : 1;
guint jtype : 2;
PROP_ANGLE,
PROP_MAX_WIDTH_CHARS,
PROP_TRACK_VISITED_LINKS,
- PROP_LINES
+ PROP_LINES,
+ PROP_XALIGN,
+ PROP_YALIGN
};
/* When rotating ellipsizable text we want the natural size to request
PROP_JUSTIFY,
g_param_spec_enum ("justify",
P_("Justification"),
- P_("The alignment of the lines in the text of the label relative to each other. This does NOT affect the alignment of the label within its allocation. See GtkMisc::xalign for that"),
+ P_("The alignment of the lines in the text of the label relative to each other. This does NOT affect the alignment of the label within its allocation. See GtkLabel:xalign for that"),
GTK_TYPE_JUSTIFICATION,
GTK_JUSTIFY_LEFT,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+ /**
+ * GtkLabel:xalign:
+ *
+ * The xalign property determines the horizontal aligment of the label text
+ * inside the labels size allocation. Compare this to #GtkWidget:halign,
+ * which determines how the labels size allocation is positioned in the
+ * space available for the label.
+ *
+ * Since: 3.16
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_XALIGN,
+ g_param_spec_float ("xalign",
+ P_("X align"),
+ P_("The horizontal alignment, from 0 (left) to 1 (right). Reversed for RTL layouts."),
+ 0.0, 1.0, 0.5,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+
+ /**
+ * GtkLabel:yalign:
+ *
+ * The yalign property determines the vertical aligment of the label text
+ * inside the labels size allocation. Compare this to #GtkWidget:valign,
+ * which determines how the labels size allocation is positioned in the
+ * space available for the label.
+ *
+ * Since: 3.16
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_YALIGN,
+ g_param_spec_float ("yalign",
+ P_("Y align"),
+ P_("The vertical alignment, from 0 (top) to 1 (bottom)"),
+ 0.0, 1.0, 0.5,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+
g_object_class_install_property (gobject_class,
PROP_PATTERN,
g_param_spec_string ("pattern",
case PROP_LINES:
gtk_label_set_lines (label, g_value_get_int (value));
break;
+ case PROP_XALIGN:
+ gtk_label_set_xalign (label, g_value_get_float (value));
+ break;
+ case PROP_YALIGN:
+ gtk_label_set_yalign (label, g_value_get_float (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
case PROP_LINES:
g_value_set_int (value, gtk_label_get_lines (label));
break;
+ case PROP_XALIGN:
+ g_value_set_float (value, gtk_label_get_xalign (label));
+ break;
+ case PROP_YALIGN:
+ g_value_set_float (value, gtk_label_get_yalign (label));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
priv->label = NULL;
priv->lines = -1;
+ priv->xalign = 0.5;
+ priv->yalign = 0.5;
+
priv->jtype = GTK_JUSTIFY_LEFT;
priv->wrap = FALSE;
priv->wrap_mode = PANGO_WRAP_WORD;
widget = GTK_WIDGET (label);
priv = label->priv;
+ xalign = priv->xalign;
+ yalign = priv->yalign;
+
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
- gtk_misc_get_alignment (GTK_MISC (label), &xalign, &yalign);
_gtk_misc_get_padding_and_border (GTK_MISC (label), &border);
G_GNUC_END_IGNORE_DEPRECATIONS
return FALSE;
}
+
+/**
+ * gtk_label_set_xalign:
+ * @label: a #GtkLabel
+ * @xalign: the new xalign value, between 0 and 1
+ *
+ * Sets the #GtkLabel:xalign property for @label.
+ *
+ * Since: 3.16
+ */
+void
+gtk_label_set_xalign (GtkLabel *label,
+ gfloat xalign)
+{
+ g_return_if_fail (GTK_IS_LABEL (label));
+
+ xalign = CLAMP (xalign, 0.0, 1.0);
+
+ if (label->priv->xalign == xalign)
+ return;
+
+ label->priv->xalign = xalign;
+
+ gtk_widget_queue_draw (GTK_WIDGET (label));
+ g_object_notify (G_OBJECT (label), "xalign");
+}
+
+/**
+ * gtk_label_get_xalign:
+ * @label: a #GtkLabel
+ *
+ * Gets the #GtkLabel:xalign property for @label.
+ *
+ * Returns: the xalign property
+ *
+ * Since: 3.16
+ */
+gfloat
+gtk_label_get_xalign (GtkLabel *label)
+{
+ g_return_val_if_fail (GTK_IS_LABEL (label), 0.5);
+
+ return label->priv->xalign;
+}
+
+/**
+ * gtk_label_set_yalign:
+ * @label: a #GtkLabel
+ * @xalign: the new yalign value, between 0 and 1
+ *
+ * Sets the #GtkLabel:yalign property for @label.
+ *
+ * Since: 3.16
+ */
+void
+gtk_label_set_yalign (GtkLabel *label,
+ gfloat yalign)
+{
+ g_return_if_fail (GTK_IS_LABEL (label));
+
+ yalign = CLAMP (yalign, 0.0, 1.0);
+
+ if (label->priv->yalign == yalign)
+ return;
+
+ label->priv->yalign = yalign;
+
+ gtk_widget_queue_draw (GTK_WIDGET (label));
+ g_object_notify (G_OBJECT (label), "yalign");
+}
+
+/**
+ * gtk_label_get_yalign:
+ * @label: a #GtkLabel
+ *
+ * Gets the #GtkLabel:yalign property for @label.
+ *
+ * Returns: the yalign property
+ *
+ * Since: 3.16
+ */
+gfloat
+gtk_label_get_yalign (GtkLabel *label)
+{
+ g_return_val_if_fail (GTK_IS_LABEL (label), 0.5);
+
+ return label->priv->yalign;
+}